package com.gome.han.cloud.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.gome.han.springcloud.api.bean.User;

/**
* @author hanpeng
* @version 创建时间：2020年8月8日 下午12:57:45
* @ClassName 类名称
* @Description 类描述
*/
@SpringBootApplication
@RestController
@EnableEurekaClient
public class Application {
	@Autowired
	private RestTemplate restTemplate;
	//private  static final String REST_URL_PREFIX="http://localhost:8081/";
	private  static final String REST_URL_PREFIX="http://SPRING-CLOUD-PROVIDER1/";
	@RequestMapping("/consumer/get/{age}")
	public User home(@PathVariable(name="age") Integer age) {
		User user = restTemplate.getForObject(REST_URL_PREFIX+"getUser/"+age,  User.class);
		return user;
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class);
	}
	
}
